<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta content="IE=edge" http-equiv="X-UA-Compatible">
    <meta content="width=device-width, initial-scale=1.0" name="viewport">
    <title>博客详情页</title>
    <link href="common.css" rel="stylesheet">
    <link href="blog_detail.css" rel="stylesheet">
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
       <!--引入editor.md的依赖-->
       <link href="editor.md/css/editormd.min.css" rel="stylesheet" />
       <!-- <script src="js/jquery.min.js"></script> -->
       <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
       <script src="editor.md/lib/marked.min.js"></script>
       <script src="editor.md/lib/prettify.min.js"></script>
       <script src="editor.md/editormd.js"></script>
       
</head>
<body>
    <div class="nav">
        <img src="C:\Users\Lenovo\Desktop\QQ图片20221113100627.jpg">
        <span class="title">我的博客系统</span>
        <!--spacer来占位-->
        <div class="spacer"></div>
        <a href="blog_list.html">主页</a>
        <a href="blog_edit.html">写博客</a>
        <a href="logout">注销</a>
        <a href="#" id="delete-btn">删除</a>
    </div>
     <!--这个div表示页面的主区-->
     <div class="container">
        <!--左侧用户区-->
        <div class="container-left">
            <!--用这个元素表示用户信息-->
            <div class="card">
                <!--用户头像-->
                <img alt="" src="C:\Users\Lenovo\Desktop\111\89333026_p0_master1200.jpg">
                <!--用户名字-->
                <h3>云庆白</h3>
                <!--github地址-->
                <a href="#">github地址</a>
                <div class="counter">
                    <span>文章</span>
                    <span>分类</span>
                </div>
                <div class="counter">
                    <span>2</span>
                    <span>1</span>
                </div>
            </div>
        </div>
        <!--右侧内容区-->
        <div class="container-right">
            <div class="blog-detail">
                <h3></h3>
                <div class="date"></div>
                <!--#content 这个div表示存放博客的正文-->
                <div id="content">
                    
                </div>
            </div>
        </div>
     </div>
     <!--通过ajax获取到博客详情页-->
     <script src="js/app.js"></script>
     <script>
        function getBlog(){
            $.ajax({
                type:'get',
                url:'blog'+location.search,
                success:function(body){
                    let h3=document.querySelector('.blog-detail>h3');
                    h3.innerHTML=body.title;
                    let dateDiv=document.querySelector('.blog-detail>.date');
                    dateDiv.innerHTML=body.postTime;
                    // let contentDiv=document.querySelector('#content');
                    // contentDiv.innerHTML=body.content;
                    //此处使用editor.md来进行渲染
                    editormd.markdownToHTML('content',{markdown:body.content});
                }
            });
        }
        getBlog();
        getLoginStatus();
        function getUserInfo(){
            $.ajax({
                type:'get',
                url:'userInfo'+location.search,
                success:function(body){
                    let h3=document.querySelector(".container-left>.card>h3");
                    h3.innerHTML=body.username;
                }
            });
        }
        getUserInfo();

        function updateDeleteURL(){
            let deleteBtn=document.querySelector("#delete-btn");
            deleteBtn.href="blog_delete"+location.href;
        }
        updateDeleteURL();
     </script>
</body>
</html>